<?php

if (get_magic_quotes_gpc() == 1) 
{
	$_GET['id'] = isset($_GET['id']) ? stripslashes($_GET['id']) : null;
	$_GET['msg'] = isset($_GET['msg']) ? stripslashes($_GET['msg']) : null;
	$_GET['lat'] = isset($_GET['lat']) ? stripslashes($_GET['lat']) : null;
	$_GET['long'] = isset($_GET['long']) ? stripslashes($_GET['long']) : null;
}

if(!isset($_GET['type'])) 
{
	echo "Undefined type (read or write)";
	die;
}

if($_GET['type'] == 'read')
	$url = "http://comeetdb4.weedo.fr/meetme/read.php?id=".urlencode($_GET['id'])."&format=xml&crypt";
else
	$url = "http://comeetdb4.weedo.fr/meetme/write.php?id=".urlencode($_GET['id'])."&lat=".urlencode($_GET['lat'])."&long=".urlencode($_GET['long'])."&msg=".urlencode			($_GET['msg'])."&crypt";
	
$tmp = file_get_contents($url);

if($_GET['type'] == 'read')
{
	$xml = simplexml_load_string($tmp);
	echo 'id : '. $xml->id.'<br />Message : '. $xml->msg.'<br />Date : '. $xml->timestamp;
	echo '<br /><a href=http://maps.google.fr/maps?ie=UTF8&ll='.$xml->lat.','.$xml->long.'&z=18> The map </a>';
}
else
	echo $tmp;
?>